/**
 * Created by Delicate on 2018/1/3.
 */
import React from 'react';
import {
    StyleSheet,
    View,
} from 'react-native';

import NavBar from '../../components/NavBarView'
import ATBtn from '../../components/AssetTypeIconBtn'
import AssetTypeDict from '../../config/dict/AssetTypeStatic'

let _self;

class Views extends React.Component {

    constructor(props) {
        super(props)
        _self = this;
        this.state = {
            assetTypeDetails: [
                {
                    icon: AssetTypeDict["1512549651341"],
                    name: '供应链资产',
                    onPress(){
                        _self.skip('AssetSummary', {type: 3, name: '供应链资产'});
                    }
                }, {
                    icon: AssetTypeDict["1512549677257"],
                    name: '抵质押类',
                    onPress(){
                        _self.skip('AssetSummary', {type: 5, name: '抵质押类'});
                    }
                }, {
                    icon: AssetTypeDict["1512549671473"],
                    name: '企业贷款类',
                    onPress(){
                        _self.skip('AssetSummary', {type: 4, name: '企业贷款类'});
                    }
                }, {
                    icon: AssetTypeDict["1512549691080"],
                    name: '租赁资产',
                    onPress(){
                        _self.skip('AssetSummary', {type: 6, name: '租赁资产'});
                    }
                }, {
                    icon: AssetTypeDict["1512549695449"],
                    name: '公司债权类',
                    onPress(){
                        _self.skip('AssetSummary', {type: 7, name: '公司债权类'});
                    }
                }, {
                    icon: AssetTypeDict["1512549711155"],
                    name: '金融债权类',
                    onPress(){
                        _self.skip('AssetSummary', {type: 10, name: '金融债权类'});
                    }
                }, {
                    icon: AssetTypeDict["1512549776653"],
                    name: '票据类资产',
                    onPress(){
                        _self.skip('AssetSummary', {type: 11, name: '票据类资产'});
                    }
                }, {
                    icon: AssetTypeDict["1512549700463"],
                    name: 'PPP项目',
                    onPress(){
                        _self.skip('AssetSummary',{type: 8, name: 'PPP项目'});
                    }
                }, {
                    icon: AssetTypeDict["1512549705355"],
                    name: '信托收益权类',
                    onPress(){
                        _self.skip('AssetSummary',{type: 9, name: '信托收益权类'});
                    }
                }
            ]
        }
    }

    componentWillMount() {

    }

    componentDidMount() {

    }

    //跳转封装
    skip(route, params) {
        _self.props.navigation.navigate(route, params ? params : {});
    }

    render() {
        return (
            <View style={base.baseOuter}>
                <NavBar host={this} title={'全部类型'}/>
                <View style={styles.container}>
                    {
                        this.state.assetTypeDetails.map((item,index)=>{
                            return(
                                <ATBtn
                                    key={index}
                                    style={styles.item}
                                    onPress={()=>item.onPress()}
                                    text={item.name}
                                    icon={item.icon}
                                    wrap={3}/>
                            )
                        })
                    }
                </View>
            </View>
        )
    }
}

const styles = StyleSheet.create({
    outer: {
    },
    container: {
        flex: 1,
        flexDirection: 'row',
        flexWrap: 'wrap',
        paddingVertical: layout.GAP_VERTICAL_LARGE,
        backgroundColor: layout.MAIN_BACKGROUND_COLOR
    },
    item: {
        height: layout.height(240)
    }
})

//路由
const AssetSummaryList = {
    screen: Views,
    navigationOptions: {
        header: null,
    },
    name: 'AssetSummaryList',
    sign: false
};

export default AssetSummaryList;